<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
	<title>View Forum Post</title>
</h:head>
<f:view>
	<body>
		<ui:composition template="../includes/template.xhtml">
			<ui:define name="mainbody">
				<h:form>
					<p:panel id="panel" header="View Forum Post"
						style="min-height: 550px" styleClass="prime_panel">
						<p:growl id="growl" showDetail="true" sticky="false"
							autoUpdate="true" showSummary="false" />

						<div id="parentPost">
						<p:fieldset legend="#{viewPostBean.parentPost.subject}" toggleable="true" toggleSpeed="500">  
							<h:panelGrid columns="1" cellpadding="5">
								<h:outputText value="#{viewPostBean.parentPost.message}" />
							</h:panelGrid>
						</p:fieldset>
						</div>
						<br />
						<div id="childPosts">
							<p:dataTable id="dataTable" var="post"
								value="#{viewPostBean.childPosts}" paginator="true" rows="10"
								paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="5,10,15" paginatorPosition="bottom">

								<p:column>
									<f:facet name="header">
										<h:outputText value="Replies" />
									</f:facet>
									<h:outputText value="#{post.message}" />
								</p:column>
							</p:dataTable>
						</div>
						<br />
						<div id="answer">
							<h:panelGrid id="display" columns="2" cellpadding="4">
								<h:outputText value="Your Reply : " />
								<h:inputTextarea id="reply" value="#{viewPostBean.reply}"
									required="true" requiredMessage="Please enter a reply"
									rows="5" cols="100" />

								<h:outputText />
								<p:commandButton value="Post" id="btnPost" process="@all"
									update="panel" actionListener="#{viewPostBean.savePost}" />
							</h:panelGrid>

						</div>
					</p:panel>
				</h:form>
			</ui:define>
		</ui:composition>
	</body>
</f:view>
</html>